﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace NghiSonStyle
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
        public static List<ImageEntity> GetCurrentTime(string name)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
            con.Open();
            SqlCommand cmd = new SqlCommand("Select ImagePath,ImageName,Kieu from ImagesPath ORDER BY Kieu", con);
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            con.Close();
            List<ImageEntity> list = new List<ImageEntity>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                list.Add(new ImageEntity(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString()));
            }
            return list;
        }
        public class ImageEntity
        {
            public string ImagePath { get; set; }
            public string ImageName { get; set; }
            public ImageEntity(string ImagePath, string ImageName)
            {
                this.ImagePath = ImagePath;
                this.ImageName = ImageName;
            }
        }

    }
}
